org.jboss.byteman.sample.helper
Class ThreadHistoryMonitorHelper

java.lang.Object
  extended by org.jboss.byteman.rule.helper.Helper
      extended by org.jboss.byteman.sample.helper.ThreadHistoryMonitorHelper
All Implemented Interfaces:
ThreadHistoryMonitorHelperMXBean

public class ThreadHistoryMonitorHelper
extends Helper
implements ThreadHistoryMonitorHelperMXBean

Helper class used by ThreadHistoryMonitorHelper script to trace thread operations. This is essentially an extension of the ThreadMonitorHelper which uses maps to store the thread history rather than writing it out. The helper also implements ThreadHistoryMonitorHelperMXBean to allow this class to be registered as an mbean @see #registerHelperMBean(String).


Field Summary
 
Fields inherited from class org.jboss.byteman.rule.helper.Helper
rule
 
Constructor Summary
protected ThreadHistoryMonitorHelper(Rule rule)
           
 
Method Summary
static void activated()
          Looks to the org.jboss.byteman.sample.helper.debug system property to set the class DEBUG mode flag.
 ThreadMonitorEvent[] getCreateEvents()
          Get the array of thread creation events.
 java.lang.String getEventReport()
          Get a string description of all thread events.
 ThreadMonitorEvent[] getExitEvents()
          Get the array of thread exit events.
 ThreadMonitorEvent[] getRunEvents()
          Get the array of Runnable.run events.
 ThreadMonitorEvent[] getStartEvents()
          Get the array of thread start events.
static void installed(Rule rule)
           
 void registerHelperMBean(java.lang.String name)
          Register the INSTANCE as an mbean under the given name.
 void traceCreate(java.lang.Thread thread, int depth)
          trace creation of the supplied thread to System.out this should only be triggered from the constructor for class java.lang.Thread"
 void traceExit(java.lang.Thread thread)
          trace exit of the supplied thread to System.out this should only be triggered from the call to java.lang.Thread.exit"
 void traceRun(java.lang.Runnable runnable)
          trace run of the supplied Runnable to System.out this should only be triggered from a call to an implementation of java.lang.Runnable.run"
 void traceStart(java.lang.Thread thread)
          trace start of the supplied thread to System.out this should only be triggered from the call to java.lang.Thread.start"
 void writeAllEventsToFile(java.lang.String path)
          Write all events to the file given by path
 void writeAllEventsToFile(java.lang.String path, int sampleCount)
          Write all events to the file given by path, repeating sampleCount times at 5 second intervals.
 void writeEventsToFile(java.lang.String type, java.lang.String path)
          Write a report of all events of the indicated type to the given path.
 
Methods inherited from class org.jboss.byteman.rule.helper.Helper
addCountDown, callerCheck, callerEquals, callerEquals, callerEquals, callerEquals, callerEquals, callerEquals, callerEquals, callerEquals, callerEquals, callerMatches, callerMatches, callerMatches, callerMatches, callerMatches, callerMatches, callerMatches, callerMatches, callerMatches, clear, closeTrace, countDown, createCountDown, createCounter, createCounter, createJoin, createRendezvous, createRendezvous, createTimer, deactivated, debug, decrementCounter, delay, deleteCounter, deleteRendezvous, deleteTimer, flag, flagged, formatStack, formatStack, formatStack, formatStack, formatStackBetween, formatStackBetween, formatStackBetween, formatStackBetween, formatStackBetween, formatStackBetween, formatStackBetweenMatches, formatStackBetweenMatches, formatStackBetweenMatches, formatStackBetweenMatches, formatStackBetweenMatches, formatStackBetweenMatches, formatStackMatching, formatStackMatching, formatStackMatching, formatStackMatching, formatStackMatching, formatStackMatching, formatStackRange, getCountDown, getElapsedTimeFromTimer, getRendezvous, getStack, incrementCounter, incrementCounter, isCountDown, isJoin, isRendezvous, joinEnlist, joinWait, killJVM, killJVM, killThread, matchIndex, openTrace, openTrace, printFrame, printlnFrame, readCounter, readCounter, rendezvous, resetTimer, setTriggering, signalKill, signalKill, signalThrow, signalThrow, signalWake, signalWake, toString, trace, trace, traceClose, traceln, traceln, traceOpen, traceOpen, traceStack, traceStack, traceStack, traceStack, traceStack, traceStack, traceStackBetween, traceStackBetween, traceStackBetween, traceStackBetween, traceStackBetween, traceStackBetween, traceStackBetween, traceStackBetween, traceStackBetween, traceStackBetweenMatches, traceStackBetweenMatches, traceStackBetweenMatches, traceStackBetweenMatches, traceStackBetweenMatches, traceStackBetweenMatches, traceStackBetweenMatches, traceStackBetweenMatches, traceStackBetweenMatches, traceStackMatching, traceStackMatching, traceStackMatching, traceStackMatching, traceStackMatching, traceStackMatching, traceStackMatching, traceStackMatching, traceStackMatching, traceStackRange, triggerIndex, uninstalled, waitFor, waitFor, waiting
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

ThreadHistoryMonitorHelper

protected ThreadHistoryMonitorHelper(Rule rule)
Method Detail

activated

public static void activated()
Looks to the org.jboss.byteman.sample.helper.debug system property to set the class DEBUG mode flag.


installed

public static void installed(Rule rule)

registerHelperMBean

public void registerHelperMBean(java.lang.String name)
Register the INSTANCE as an mbean under the given name.

Parameters:
name - - the object name string to register the INSTANCE under

getCreateEvents

public ThreadMonitorEvent[] getCreateEvents()
Description copied from interface: ThreadHistoryMonitorHelperMXBean
Get the array of thread creation events.

Specified by:
getCreateEvents in interface ThreadHistoryMonitorHelperMXBean
Returns:
the array of thread creation events in the order of occurrence.

getStartEvents

public ThreadMonitorEvent[] getStartEvents()
Description copied from interface: ThreadHistoryMonitorHelperMXBean
Get the array of thread start events.

Specified by:
getStartEvents in interface ThreadHistoryMonitorHelperMXBean
Returns:
the array of thread start events in the order of occurrence.

getExitEvents

public ThreadMonitorEvent[] getExitEvents()
Description copied from interface: ThreadHistoryMonitorHelperMXBean
Get the array of thread exit events.

Specified by:
getExitEvents in interface ThreadHistoryMonitorHelperMXBean
Returns:
the array of thread exit events in the order of occurrence.

getRunEvents

public ThreadMonitorEvent[] getRunEvents()
Description copied from interface: ThreadHistoryMonitorHelperMXBean
Get the array of Runnable.run events.

Specified by:
getRunEvents in interface ThreadHistoryMonitorHelperMXBean
Returns:
the array of Runnable.run events in the order of occurrence.

getEventReport

public java.lang.String getEventReport()
                                throws java.io.IOException
Description copied from interface: ThreadHistoryMonitorHelperMXBean
Get a string description of all thread events. This is the same event information written by ThreadHistoryMonitorHelperMXBean.writeAllEventsToFile(String).

Specified by:
getEventReport in interface ThreadHistoryMonitorHelperMXBean
Returns:
a formatted text description of all thread events.
Throws:
java.io.IOException

writeEventsToFile

public void writeEventsToFile(java.lang.String type,
                              java.lang.String path)
                       throws java.io.IOException
Description copied from interface: ThreadHistoryMonitorHelperMXBean
Write a report of all events of the indicated type to the given path.

Specified by:
writeEventsToFile in interface ThreadHistoryMonitorHelperMXBean
Parameters:
type - - one of create, start, exit, run; case insensitive
path - - the pathname of the file to write the event report to.
Throws:
java.io.IOException

writeAllEventsToFile

public void writeAllEventsToFile(java.lang.String path)
                          throws java.io.IOException
Write all events to the file given by path

Specified by:
writeAllEventsToFile in interface ThreadHistoryMonitorHelperMXBean
Parameters:
path -
Throws:
java.io.IOException

writeAllEventsToFile

public void writeAllEventsToFile(java.lang.String path,
                                 int sampleCount)
                          throws java.io.IOException
Write all events to the file given by path, repeating sampleCount times at 5 second intervals. The actual filename of each sample report will be either path-n where n = [0,sampleCount] if path does not contain a suffix, for example: /tmp/report-0 /tmp/report-1 /tmp/report-3 or pathbase-n.suffix if there is a '.' delimited suffix (.txt), for example: /tmp/report-0.txt /tmp/report-1.txt /tmp/report-3.txt

Parameters:
path - - the path to the event report file
sampleCount - - the number of samples to take
Throws:
java.io.IOException - - thrown on any IO failure

traceCreate

public void traceCreate(java.lang.Thread thread,
                        int depth)
trace creation of the supplied thread to System.out this should only be triggered from the constructor for class java.lang.Thread"

Parameters:
thread - the newly created thread

traceStart

public void traceStart(java.lang.Thread thread)
trace start of the supplied thread to System.out this should only be triggered from the call to java.lang.Thread.start"

Parameters:
thread - the newly starting thread

traceExit

public void traceExit(java.lang.Thread thread)
trace exit of the supplied thread to System.out this should only be triggered from the call to java.lang.Thread.exit"

Parameters:
thread - the exiting thread

traceRun

public void traceRun(java.lang.Runnable runnable)
trace run of the supplied Runnable to System.out this should only be triggered from a call to an implementation of java.lang.Runnable.run"

Parameters:
runnable - the runnable being run


Copyright © 2011. All Rights Reserved.